﻿package com.youdo.ad.core {
	import com.youdo.ad.core.XAdInstance;
	
	import flash.geom.Rectangle;
	
	
	/**
	 * 
	 */
	public class XAdSlot {
		private var proxied : Object;
		/**
		 * 
		 */
		public function XAdSlot(proxiedObj : Object) {
			//
			this.proxied = (proxiedObj != null) ? proxiedObj : {};
		}


		/**
		 * 
		 */
		public function getId() : String {
			return this.proxied.getId();
		}

		/**
		 * preload
		 * 
		 * @see play()
		 */
		public function preload() : void {
			this.proxied.preload();
		}

		/**
		 * play ad slot
		 * 
		 * @see preload()
		 * @see stop()
		 * @see pause()
		 */
		public function play() : void {
			this.proxied.play();
		}

		/**
		 * stop slot
		 * 
		 * @see play()
		 * @see pause()
		 */
		public function stop() : void {
			this.proxied.stop();
		}

		/**
		 * pause slot
		 * 
		 * @see play()
		 * @see stop()
		 */
		public function pause() : void {
			this.proxied.pause();
		}

		/**
		 * @return true indicate has companion ads, otherwise no.
		 */
		public function hasCompanion() : Boolean {
			return this.proxied.hasCompanion();
		}

		/**
		 * 
		 * @param estimate
		 * @return total duration of slot
		 */
		public function getTotalDuration(estimate : Boolean = false) : int {
			return this.proxied.getTotalDuration(estimate);
		}

		/**
		 * 
		 */
		public function getTotalBytes(estimate : Boolean = false) : int {
			return this.proxied.getTotalBytes(estimate)
		}

		/**
		 * 
		 */
		public function getBytesLoaded(estimate : Boolean = false) : int {
			return this.proxied.getBytesLoaded(estimate);
		}

		/**
		 * time position of slot
		 * 
		 * @return -1 indicate it's non-temporal slot, otherwise return the time position of the slot
		 */
		public function getTimePosition() : int {
			return this.proxied.getTimePosition();
		}

		/**
		 * get the rectangle info of slot.
		 * return {x,y,width,height}
		 */
		public function getRectangle() : Rectangle {
			return this.proxied.getRectangle();
		}

		/**
		 * 
		 */
		public function getAdInstances() : Vector.<XAdInstance> {
			var results:Vector.<XAdInstance> = new Vector.<XAdInstance>();
			var arr:Array = this.proxied.getAdInstances();
			for(var i:int=0; i<arr.length;i++){
				results.push(new XAdInstance(arr[i]));
			}
			return results;
		}

		/**
		 * @see com.kt.ad.behavior.AdSlotType
		 */
		public function getType() : XAdSlotType {
			return XAdSlotType.getEnumeration(this.proxied.getType());
		}

		/**
		 * get ad count
		 */
		public function getAdCount() : uint {
			return this.proxied.getAdCount();
		}

		/**
		 * get playhead time of slot
		 */
		public function getPlayheadTime(estimate : Boolean = false) : Number {
			return this.proxied.getPlayheadTime(estimate);
		}

		/**
		 * play companion ads
		 */
		public function playCompanion() : void {
			this.proxied.playCompanion();
		}

		/**
		 * ignore current Ad and keep playing if has next ad
		 */
		public function skipCurrentAd() : void {
			this.proxied.skipCurrentAd();
		}
	}
}
